<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Messages extends Model
{
    use HasFactory;

    protected $table = "messages";

    public function getMessagesList($userId, $page, $size)
    {
        $stdData = array();
        $offset = ($page - 1) * $size;
        $res = self::where('user_id', $userId)->offset($offset)->limit($size)->get();
        if($res)
        {
            $stdData = $res->toArray();
        }
        return $stdData;
    }
}
